package com.mcjtf.prefix.bridge;

import com.mcjtf.prefix.PrefixManager;
import com.mcjtf.prefix.model.User;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;

public class PrefixPlaceholders extends PlaceholderExpansion {
    @Override
    public String getAuthor() {
        return "john180";
    }

    @Override
    public String getIdentifier() {
        return "prefix";
    }

    @Override
    public String getVersion() {
        return "1.0.0";
    }

    @Override
    public String onPlaceholderRequest(Player player, String identifier) {
        User user = PrefixManager.getInstance().getPrefixService().getUser(player.getName());
        if (user == null) {
            return null;
        }
        if (identifier.equalsIgnoreCase("prefix")) {
            return user.getPrefix();
        } else if (identifier.equalsIgnoreCase("suffix")) {
            return user.getSuffix();
        }
        return null;
    }
}
